package com.salesmonitoring.accounts.controller;

import java.util.ArrayList;

import com.salesmonitoring.accounts.dao.MarketingAssistantDaoImpl;
import com.salesmonitoring.accounts.dao.MarketingAssistantRefRsCodDaoImpl;
import com.salesmonitoring.accounts.dao.MarketingAssistantRefRsCodDaoImpl;
import com.salesmonitoring.model.Motor;
import com.salesmonitoring.model.Transaction;

public class MarketingAssistantController {

	private static MarketingAssistantController marketingAssistantController;
	
	public static synchronized MarketingAssistantController getInstance() {
		if(marketingAssistantController == null) 
			marketingAssistantController = new MarketingAssistantController();
		
		return marketingAssistantController;
	}
	
	public void insertUser(String name, String email, Integer contact) {
		
		MarketingAssistantDaoImpl dao = MarketingAssistantDaoImpl.getInstance();
		dao.insertUser(name, email, contact);
		
	}
	
	public ArrayList<String> getAllRsCode() {
		
		MarketingAssistantRefRsCodDaoImpl dao = MarketingAssistantRefRsCodDaoImpl.getInstance();
		ArrayList<String> rsCodList = dao.getAllRsCode();
		return rsCodList;
		
	}
	
	public int addReport(ArrayList<Object> details) {
		
		MarketingAssistantDaoImpl marketingAssistantDaoImpl = MarketingAssistantDaoImpl.getInstance();
		
		return marketingAssistantDaoImpl.addReport(details);
		
	}
	
	public ArrayList<Transaction> getReports(String officer, String month, String year) {
		
		ArrayList<Transaction> reports = new ArrayList<Transaction>();
		String value = "";
		if(month.equals("Jan")) {
			value = "01";
		} else if(month.equals("Feb")) { 
			value = "02";
		} else if(month.equals("Mar")) { 
			value = "03";
		} else if(month.equals("Apr")) { 
			value = "04";
		} else if(month.equals("May")) { 
			value = "05";
		} else if(month.equals("Jun")) { 
			value = "06";
		} else if(month.equals("Jul")) { 
			value = "07";
		} else if(month.equals("Aug")) { 
			value = "08";
		} else if(month.equals("Sep")) { 
			value = "09";
		} else if(month.equals("Oct")) { 
			value = "10";
		} else if(month.equals("Nov")) { 
			value = "11";
		} else if(month.equals("Dec")) { 
			value = "12";
		} 
		
		MarketingAssistantDaoImpl marketingAssistantDaoImpl = MarketingAssistantDaoImpl.getInstance();
		reports = marketingAssistantDaoImpl.getReports(officer, value, year);
		
		return reports;
		
	}
	
	public String[] getAllEngineNumbers() {
		
		MarketingAssistantDaoImpl marketingAssistantDaoImpl = MarketingAssistantDaoImpl.getInstance();
		
		return marketingAssistantDaoImpl.getAllStringEngineNumbers();
		
	}
	
	public Motor getMotorByEngineNumber(String number) {
		
		MarketingAssistantDaoImpl marketingAssistantDaoImpl = MarketingAssistantDaoImpl.getInstance();
		
		return marketingAssistantDaoImpl.getMotorByEngineNumber(number);
		
	}
}
